package com.anntly.context;

/**
 * @Author：Anntly
 * @Package：com.anntly.context
 * @Project：dbRouter
 * @name：DbContextHolder
 * @Date：2024/7/3 8:25
 * @Filename：DbContextHolder
 */
public class DbContextHolder {

    private static final ThreadLocal<String> DB_ROUTE_KEY = new ThreadLocal<>();
    private static final ThreadLocal<String> TB_ROUTE_KEY = new ThreadLocal<>();

    public static void setDbRouteKey(String dbRouteKey) {
        DB_ROUTE_KEY.set(dbRouteKey);
    }

    public static String getDbRouteKey() {
        return DB_ROUTE_KEY.get();
    }

    public static void setTbRouteKey(String tbRouteKey) {
        TB_ROUTE_KEY.set(tbRouteKey);
    }

    public static String getTbRouteKey() {
        return TB_ROUTE_KEY.get();
    }

    public static void clear(){
        DB_ROUTE_KEY.remove();
        TB_ROUTE_KEY.remove();
    }

}
